﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace _071.EFCore一对一
{
	public class OrderConfig : IEntityTypeConfiguration<Order>
	{
		public void Configure(EntityTypeBuilder<Order> builder)
		{
			// 对应的表
			builder.ToTable("T_Orders");
			builder.HasOne<Delivery>(o => o.Delivery)
				.WithOne(d => d.Order).HasForeignKey<Delivery>(d => d.OrderId);
		}
	}
}
